#include <stdio.h>
#include <stdbool.h>
bool isruny(int y);
int main(void){
	int a,b,c,i;
	scanf("%d/%d/%d",&a,&b,&c);
	int pinyear[]={31,28,31,30,31,30,31,31,30,31,30,31}, runyear[]={31,29,31,30,31,30,31,31,30,31,30,31},sum=c;	
	if(isruny(a)){
		for(i=0;i<b-1;i++){
			sum+=runyear[i];
		}
	}else{
		for(i=0;i<b-1;i++){
			sum+=pinyear[i];
		}
	}
	printf("%d",sum);
	return 0;
}
bool isruny(int y){
	bool isruny=false;
	if((y%4==0&&y%100!=0)||y%400==0){
		isruny=true;
	}
	return isruny;
}

